<?php

namespace Modules\ShopAdmin\Models;
use Illuminate\Support\Facades\DB;   
class ShopProductAttrbuteValue extends BaseShopModel
{	
	/**
     * @name  关联商品属性
     */
    public function attrbute_key_to()
    {
        return $this->belongsTo('Modules\ShopAdmin\Models\ShopProductAttrbuteKey','attrbute_key_id','id');
    }
	/**
     * @name  解析列表数据
     */
    public static function attrbute_value_list($data)
    {
        foreach($data as $k=>$v){
			$data[$k]['key_name'] = $v['attrbute_key_to']['name'];
			$data[$k]['type_title'] = DB::table('shop_product_types')->where(['id'=>$v['attrbute_key_to']['product_type_id']])->value('title');
		}
		return $data;
    }
	
}
